{include file="public/_meta" /}
<body>
<style>
    .required_b{
        color: red;
    }
</style>
<div class="wrapper">

    {include file="public/_header" /}

    <!-- Sidebar -->
    {include file="public/_menu" /}
    <!-- End Sidebar -->

    <div class="main-panel">

        <div class="content">
            <div class="page-inner">

                <!-- 面包屑 -->
                {include file="public/_page_header" /}

                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <div class="d-flex align-items-center">
                                    <h4 class="card-title">商户ROI统计</h4>
                                    <!--<button class="btn btn-primary btn-round ml-auto" data-toggle="modal" data-target="#addRowModal" onClick="add_item(0)">
                                        <i class="fa fa-plus"></i>
                                        添加
                                    </button>-->
                                </div>

                                <form class="row">


                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="name" value="{$name}" placeholder="管理员名称">
                                        </div>
                                    </div>

<!--                                    <div class="col-md-6 col-lg-2">-->
<!--                                        <div class="form-group">-->

<!--                                            <select class="form-control input-full" name="pro_id" id="pro_id">-->
<!--                                                <option value="">全部产品</option>-->
<!--                                                {volist name="products" id="vo"}-->
<!--                                                <option value="{$key}">{$vo}</option>-->
<!--                                                {/volist}-->
<!--                                            </select>-->
<!--                                        </div>-->
<!--                                    </div>-->


                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="times" id="times" value="{$times}" placeholder="创建时间" autocomplete="off">
                                        </div>
                                    </div>


                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <button type="submit" class="btn btn-primary">查询</button>
                                            <a href="{:url('admin/merchantMoneyCost')}" class="btn btn-info" style="color: white;position: absolute;left: 110px;">重置</a>
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <label> （此处刷新前提需要计算了修正成本3）</label>
                                            <div class="btn btn-info" onclick="recostprice()" style="">刷新成本</div>
                                        </div>
                                    </div>

                                </form>

                            </div>

                            <div class="layui-card-body">

                                <blockquote class="layui-elem-quote layui-quote-nm">
                                    <div class="table-responsive">
                                        <table id="add-row2" class="display table table-striped table-hover" >
                                            <thead>
                                            <tr>
                                                <th>账户币成本</th>
                                                <th>真实币成本</th>
                                                <th>分发总金额</th>
                                                <th>赠送金额</th>
                                                <th>充值服务币</th>
                                                <th>商户账户币欠费金额</th>
                                                <th>收益</th>
                                                <th>收益率</th>
                                                <th>ROI</th>
                                            </tr>
                                            </thead>

                                            <tbody>

                                            <tr>
                                                <td>{$all_xz_price3}</td>
                                                <td>{$all_xz_true_price3}</td>
                                                <td>{$all_money}</td>
                                                <td>{$all_song}</td>
                                                <td>{$fw_money}</td>
                                                <td>{$owe_money2}</td>
                                                <td>{$all_balance}</td>
                                                <td>{$all_song_rate}%</td>
                                                <td>{$roi_money}</td>
                                            </tr>

                                            </tbody>
                                        </table>


                                    </div>


                                </blockquote>
                            </div>

                            <!--<div class="layui-card-body">

                                <blockquote class="layui-elem-quote layui-quote-nm">
                                    &lt;!&ndash;<span style="margin-right: 50px;">账户币损耗：{$shunhaoPrice}</span><span style="margin-right: 50px;">真实币损耗：{$shunhaoTruePrice}</span>
                                    <span style="margin-right: 50px;">账户币成本：{$all_cmoney}</span><span style="margin-right: 50px;">真实币成本：{$all_cfmoney}</span><span style="margin-right: 50px;">账户币空耗成本：{$sunhao_money}</span><span style="margin-right: 50px;">真实币空耗成本：{$tsunhao_money}</span>&ndash;&gt;
                                    <span style="margin-right: 50px;">分发总金额：{$all_money}</span>
                                    <span style="margin-right: 50px;">赠送金额：{$all_song}</span><span style="margin-right: 50px;">充值服务币：{$fw_money}</span>
                                    <span style="margin-right: 50px;">商户账户币欠费金额：{$owe_money2}</span>&lt;!&ndash;<span style="margin-right: 50px;">真实币欠费金额：{$owe_money}</span>&ndash;&gt;<span style="margin-right: 50px;">收益：{$all_balance}</span><span style="margin-right: 50px;">收益率：{$all_song_rate}%</span><span style="margin-right: 50px;">ROI：{$roi_money}</span>
                                    <br>
                                    <span style="margin-right: 50px;">账户币成本：{$all_xz_price3}</span><span style="margin-right: 50px;">真实币成本：{$all_xz_true_price3}</span>
                                </blockquote>
                            </div>-->


                            <div class="card-body">
                                <!-- Modal -->



                                <div class="table-responsive">
                                    <table id="add-row" class="display table table-striped table-hover" >
                                        <thead>
                                        <tr>
                                            <th>账号</th>
                                            <th>名称</th>
                                            <th>账户币成本</th>
                                            <th>真实币成本</th>
                                            <!--<th>账户币成本</th>
                                            <th>真实币成本</th>
                                            <th>账户币空耗成本</th>
                                            <th>真实币空耗成本</th>-->
                                            <th>分发总金额</th>
                                            <th>赠送金额</th>
                                            <th>充值服务币</th>
                                            <th>商户账户币欠费</th>
<!--                                            <th>真实币欠费</th>-->
                                            <th>有效收益</th>
                                            <th>收益</th>
                                            <th>收益率</th>
                                            <th>ROI</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>

                                        <tbody>

                                        {volist name="infos" id="vo"}
                                        <tr>
                                            <td>{$vo.phone}</td>
                                            <td>{$vo.realname}</td>
                                            <td>{$vo.xz_price3}</td>
                                            <td>{$vo.xz_true_price3}</td>
                                            <!--<td><a href="{:url('admin/priceDetails',['aid'=>$vo.uid,'type'=>1,'times'=>$times])}">{$vo.price}</a></td>
                                            <td><a href="{:url('admin/priceDetails',['aid'=>$vo.uid,'type'=>1,'times'=>$times])}">{$vo.true_price}</a></td>
                                            <td><a href="{:url('admin/priceDetails',['aid'=>$vo.uid,'type'=>2,'times'=>$times])}">{$vo.price_sunhao}</a></td>
                                            <td><a href="{:url('admin/priceDetails',['aid'=>$vo.uid,'type'=>2,'times'=>$times])}">{$vo.tprice_sunhao}</a></td>-->
                                            <td>{$vo.all_money}</td>
                                            <td>{$vo.song_money}</td>
                                            <td>{$vo.fw_money}</td>
                                            <td><a href="{:url('admin/oweDetails',['aid'=>$vo.uid,'type'=>1,'times'=>$times])}">{$vo.owe_money2}</a></td>
<!--                                            <td><a href="{:url('admin/oweDetails',['aid'=>$vo.uid,'type'=>2,'times'=>$times])}">{$vo.owe_money}</a></td>-->

                                            <td>{$vo.valid_money}</td>
                                            <td>{$vo.shouyi_money}</td>
                                            <td>{$vo.shouyi_rate}%</td>
                                            <td>{$vo.roi_money}</td>
                                            <td><a style="font-weight: bolder; color: #0b3892;" href="merchRoi?admin_id={$vo.uid}&times={$times}">商户ROI明细</a></td>
                                        </tr>
                                        {/volist}

                                        </tbody>
                                    </table>

                                    <!-- 分页 (调取通用方法)-->

                                </div>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
        </div>

        {include file="public/_footer" /}


    </div>



</div>

{include file="public/_js" /}

</body>
<link rel="stylesheet" href="__STATIC__/multiple-select-1.6.0/dist/multiple-select.css">
<script src="__STATIC__/multiple-select-1.6.0/dist/multiple-select.js"></script>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">

    function recostprice(){
        var times=$('#times').val();
        layer.confirm('确认要刷新成本吗？',function(index){
            var loading = layer.load('加载中...', {
                shade: [0.3,'#fff'] //0.1透明度的白色背景
            });
            $.ajax({
                type: 'POST',
                url: "{:url('Admin/reMoneyCostQueue')}",
                dataType: 'json',
                data: {times:times},
                success: function(data){
                    layer.close(loading);
                    if(data.code == 1001){
                        layer.msg(data.msg,{icon:1,time:2000});
                    }else{
                        layer.msg(data.msg,{icon:2,time:2000});
                    }

                },
                error:function(data) {
                    layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
                }
            });
        });
    }

    var SCOPE = {
        'status_url':"{:url('clue/status')}",
        'delete_url':"{:url('clue/delete')}",
        'delete_url2':"{:url('clue/delete2')}",
        'item_url':"{:url('clue/edit')}",
        'item_url2':"{:url('clue/edit2')}",
        'add_url':"{:url('clue/save')}",
        'clue_url':"{:url('clue/clue_url')}",
        'city_url':"{:url('clue/getRegion')}",
        'push_rule':"{:url('clue/getMerchantPush')}",
        'push_url':"{:url('clue/findPush')}",
    };


    function loadRule(sel,selName){
        $("#"+selName+" option").each(function(){
            $(this).remove();
        });
        $("<option value=0>请选择</option>").appendTo($("#"+selName));
        if($("#"+sel).val()==0){
            return;
        }
        $.post(SCOPE.push_rule,{pid:$("#"+sel).val()},
            function(data){
                if(data.code == 1001){
                    $.each(data.data,function(idx,item){
                        $("<option value="+item.id+">【"+item.dcity+"】【"+item.dcharge_type+"】(单价"+item.price+")</option>").appendTo($("#"+selName));
                    });
                }else{
                    $("<option value='0'>请选择</option>").appendTo($("#"+selName));
                }
            }
        );
    }

    function loadRegion(sel,type_id,selName){
        $("#"+selName+" option").each(function(){
            $(this).remove();
        });
        $("<option value=0>请选择</option>").appendTo($("#"+selName));
        if($("#"+sel).val()==0){
            return;
        }
        $.post(SCOPE.city_url,{pid:$("#"+sel).val(),type:type_id},
            function(data){
                if(data.code == 1001){
                    $.each(data.data,function(idx,item){
                        $("<option value="+item.id+">"+item.name+"</option>").appendTo($("#"+selName));
                    });
                }else{
                    $("<option value='0'>请选择</option>").appendTo($("#"+selName));
                }
            }
        );
    }

    $(function(){
        var commitStatus = false;
        /*表单验证*/
        $("#form-modal").validate({
            rules:{
                clue_name:{
                    required:true,
                    maxlength:30
                },
                phone:{
                    required:true,
                    number:true,
                    minlength:11,
                    maxlength:11
                },
                age:{
                    number:true
                },
                email:{
                    email:true,
                    maxlength:100
                },
                wx_id:{
                    maxlength:30
                },
                qq:{
                    maxlength:30
                },
                remark:{
                    maxlength:300
                }

            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.add_url;
                if(commitStatus==true){
                    return false;
                }
                var province = $("#province").val();
                var city = $("#city").val();
                if(province != 0 && city == 0){
                    layer.msg('请选择市/县',{icon:2,time:2000});
                    return false;
                }
                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

    });

    //指定推送
    $(function(){
        var commitStatus = false;
        /*表单验证*/
        $("#form-modal2").validate({

            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var url = SCOPE.push_url;
                if(commitStatus==true){
                    return false;
                }

                var loading = layer.load(0, {
                    shade: true,
                    time: 10*1000
                });
                /*表单提交*/
                $(form).ajaxSubmit({
                    type: 'post',
                    url: url,
                    success: function(data){
                        if(data.code == 1001){
                            commitStatus = true;
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000
                            }, function(){
                                layer.close(loading);
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(data.msg,{icon:2,time:2000});
                            layer.close(loading);
                        }
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg(errorThrown,{icon:2,time:2000});
                    }
                });

            }
        });

    });

    function add_item(id) {
        $("input[name='id']").val(id);
        document.getElementById('form-modal').reset();
        $("#city").children().remove();
        $("<option value='0'>请选择</option>").appendTo($("#city"));
        $(".fw-mediumbold").text('添加');
    }

    function edit_item(id) {
        $("#city").children().remove();
        $("<option value='0'>请选择</option>").appendTo($("#city"));
        $.ajax({
            type: 'GET',
            url: SCOPE.item_url,
            dataType: 'json',
            data: {id:id},
            success: function(res){
                if(res.code == 1001){
                    $(".fw-mediumbold").text('编辑');
                    $("#id").val(res.data.id);
                    $("#clue_name").val(res.data.clue_name);
                    $("#phone").val(res.data.phone);
                    $("#age").val(res.data.age);
                    $("#source").val(res.data.source);
                    $("#email").val(res.data.email);
                    $("#wx_id").val(res.data.wx_id);
                    $("#qq").val(res.data.qq);
                    $("#remark").val(res.data.remark);
                    $(":radio[name='gender'][value='"+res.data.gender+"']").prop("checked","checked");
                    $("#province").val(res.data.prov);
                    if(res.data.city != ''){
                        $("#city").children().remove();
                        $("<option value='"+res.data.city+"'>"+res.data.city_name+"</option>").appendTo($("#city"));
                    }
                }else{
                    layer.msg(res.msg,{icon:2,time:2000});
                }

            },
            error:function(res) {
                layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
            }
        });
    }

    function edit_item2(id,city) {
        $("#mrule").children().remove();
        $("<option value='0'>请选择</option>").appendTo($("#mrule"));
        $.ajax({
            type: 'GET',
            url: SCOPE.item_url2,
            dataType: 'json',
            data: {id:id},
            success: function(res){
                if(res.code == 1001){
                    $(".fw-mediumbold").text('推送');
                    $("#id2").val(res.data.id);
                    $("#clue_name2").val(res.data.clue_name);
                    $("#phone2").val(res.data.phone);

                    $("#remark2").val(res.data.remark);
                    $("#city2").text(city);

                    $("#merchant").children().remove();


                    $.each(res.data.merchant,function(k,v) {
                        $("<option value='"+v.id+"'>【"+v.mer_name+"】【账号"+v.username+"】(联系电话"+v.phone+")</option>").appendTo($("#merchant"));
                    });

                }else{
                    layer.msg(res.msg,{icon:2,time:2000});
                }

            },
            error:function(res) {
                layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
            }
        });
    }



    /*删除*/
    function admin_del(obj,id){
        layer.confirm('确认要直接删除,不退款吗？',function(index){
            $.ajax({
                type: 'POST',
                url: SCOPE.delete_url,
                dataType: 'json',
                data: {id:id},
                success: function(data){
                    if(data.code == 1001){
                        $(obj).parents("tr").remove();
                        layer.msg('删除线索成功!',{icon:1,time:2000});
                    }else{
                        layer.msg(data.msg,{icon:2,time:2000});
                    }

                },
                error:function(data) {
                    layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
                }
            });
        });
    }

    /*删除*/
    function admin_del2(obj,id){
        layer.confirm('确认要删除并且退款吗？',function(index){
            $.ajax({
                type: 'POST',
                url: SCOPE.delete_url2,
                dataType: 'json',
                data: {id:id},
                success: function(data){
                    if(data.code == 1001){
                        $(obj).parents("tr").remove();
                        layer.msg('删除线索成功!',{icon:1,time:2000});
                    }else{
                        layer.msg(data.msg,{icon:2,time:2000});
                    }

                },
                error:function(data) {
                    layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
                }
            });
        });
    }


    /*机构-停用*/
    function admin_stop(obj,id){
        layer.confirm('确认要禁止推送吗？',function(index){
            //此处请求后台程序，下方是成功后的前台处理……
            var url = SCOPE.status_url;
            $.post(url,{status:2,id:id},function(data){
                if(data.code == 1001){
                    layer.msg('已禁止推送!',{icon: 1,time:1000},function(){
                        window.location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon: 2,time:1000});
                }

            });


        });
    }



    laydate.render({
        elem: '#times'
        ,type: 'date'
        ,range: true
    });

    $('#pro_id').val('{$pro_id}');


    $('#admin_id').multipleSelect({
        selectAll:true, //是否有全选按钮
        placeholder: "请选择管理员"
    });
    var sceneIdList ="{$admin_id}";
    sceneIdArr = sceneIdList.split(",");
    $('#admin_id option').each(function (i, content) {
        if ($.inArray($.trim(content.value), sceneIdArr) >= 0) {
            this.selected = true;
        }
    });
    //加载完勾选项后也要刷新
    $("#admin_id").multipleSelect('refresh');

</script>
</html>




























